package com.cmc.cloud.cmclink.doc.controller.admin;


import cn.hutool.core.bean.BeanUtil;
import com.cmc.cloud.cmclink.doc.constants.UrlConstants;
import com.cmc.cloud.cmclink.doc.entity.DocBkConfirmPrintSetupDO;
import com.cmc.cloud.cmclink.doc.service.DocBkConfirmPrintSetupService;
import com.cmc.cloud.cmclink.doc.vo.docbkconfirmprintsetupvo.DocBkConfirmPrintSetupCreateReqVO;
import com.cmc.cloud.cmclink.doc.vo.docbkconfirmprintsetupvo.DocBkConfirmPrintSetupPageReqVO;
import com.cmc.cloud.cmclink.doc.vo.docbkconfirmprintsetupvo.DocBkConfirmPrintSetupRespVO;
import com.cmc.cloud.cmclink.doc.vo.docbkconfirmprintsetupvo.DocBkConfirmPrintSetupUpdateReqVO;
import com.cmes.framework.biz.advice.annotations.UseResponsePropertyAdvice;
import com.cmes.framework.common.pojo.CommonResult;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

import org.springframework.validation.annotation.Validated;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import javax.validation.*;
import java.util.*;



import com.cmes.framework.common.pojo.PageResult;




/**
 * {table.classComment}前端接口Controller
 * 
 * @author codegen
 */
@Tag(name = "管理后台 - bosuccessing confirm 打印配置")
@RestController
@RequestMapping(UrlConstants.APPLICATION_URL+"/confirmPrint")
@Validated
public class DocBkConfirmPrintSetupController {

    @Resource
    private DocBkConfirmPrintSetupService docBkConfirmPrintSetupService;

    @Operation(summary = "创建bosuccessing confirm 打印配置")
    @PostMapping("/create")
    @PreAuthorize("@ss.hasPermission('doc:setupBookingConfirmPrint:add')")
    public CommonResult<Void> createDocBkConfirmPrintSetup(@Valid @RequestBody DocBkConfirmPrintSetupCreateReqVO createReqVO) {
        docBkConfirmPrintSetupService.createDocBkConfirmPrintSetup(createReqVO);
        return CommonResult.success();
    }

    @Operation(summary = "更新bosuccessing confirm 打印配置")
    @PostMapping("/update")
    @PreAuthorize("@ss.hasPermission({'doc:setupBookingConfirmPrint:edit','doc:setupBookingConfirmPrint:save'})")
    public CommonResult<Void> updateDocBkConfirmPrintSetup(@Valid @RequestBody DocBkConfirmPrintSetupUpdateReqVO updateReqVO) {
        docBkConfirmPrintSetupService.updateDocBkConfirmPrintSetup(updateReqVO);
        return CommonResult.success();
    }

    @Operation(summary = "删除bosuccessing confirm 打印配置")
    @Parameter(name = "id", description = "编号", required = true)
    @PostMapping("/delete/{id}")
    @PreAuthorize("@ss.hasPermission('doc:setupBookingConfirmPrint:delete')")
    public CommonResult<Void> deleteDocBkConfirmPrintSetup(@PathVariable("id") Long id) {
        docBkConfirmPrintSetupService.deleteDocBkConfirmPrintSetup(id);
        return CommonResult.success();
    }

    @Operation(summary = "获得bosuccessing confirm 打印配置")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    @GetMapping("/getById/{id}")
    public CommonResult<DocBkConfirmPrintSetupRespVO> getDocBkConfirmPrintSetup(@PathVariable("id") Long id) {
        DocBkConfirmPrintSetupDO docBkConfirmPrintSetup = docBkConfirmPrintSetupService.getDocBkConfirmPrintSetup(id);
        return CommonResult.success(BeanUtil.copyProperties(docBkConfirmPrintSetup, DocBkConfirmPrintSetupRespVO.class));
    }

    @Operation(summary = "获得bosuccessing confirm 打印配置列表")
    @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
    @GetMapping("/listAll")
    public CommonResult<List<DocBkConfirmPrintSetupRespVO>> getDocBkConfirmPrintSetupList(@RequestParam("ids") Collection<Long> ids) {
        List<DocBkConfirmPrintSetupDO> list = docBkConfirmPrintSetupService.getDocBkConfirmPrintSetupList(ids);
        return CommonResult.success(BeanUtil.copyToList(list,DocBkConfirmPrintSetupRespVO.class));
    }

    @Operation(summary = "获得bosuccessing confirm 打印配置分页")
    @UseResponsePropertyAdvice
    @PostMapping("/getPage")
    @PreAuthorize("@ss.hasPermission('doc:setupBookingConfirmPrint:search')")
    public CommonResult<PageResult<DocBkConfirmPrintSetupRespVO>> getDocBkConfirmPrintSetupPage(@Valid @RequestBody DocBkConfirmPrintSetupPageReqVO pageVO) {
        PageResult<DocBkConfirmPrintSetupDO> pageResult = docBkConfirmPrintSetupService.getDocBkConfirmPrintSetupPage(pageVO);
        List<DocBkConfirmPrintSetupRespVO> results = BeanUtil.copyToList(pageResult.getList(),DocBkConfirmPrintSetupRespVO.class);
        return CommonResult.success(new PageResult<>(results,pageResult.getTotal()));
    }
}
